package acwing._2LanQiao.test;
/**
 * @Project : AlgorithmLearning
 * @Package : ACWing._2LanQiao.test
 * @File : primeNumber.java
 * @Author : WangRuoyu
 * @Date : 2023/4/7 17:13
 */

import java.io.*;

public class primeNumber {

    static int getPrimes(int[] primes, int n) {
        int cnt = 0;
        boolean[] st = new boolean[n + 1];
        for (int i = 2; i <= n; ++i) {
            if (!st[i]) primes[cnt++] = i;
            for (int j = 0; primes[j] <= n / i; ++j) {
                st[primes[j] * i] = true;
                if (i % primes[j] == 0) break;
            }
        }
        return cnt;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = 100;
        int[] primes = new int[n];
        int num = getPrimes(primes, n);

        for (int i = 0; i < num; ++i) {
            System.out.print(primes[i] + " ");
        }
    }
}

